<?php

namespace CK;

use Illuminate\Database\Connection as BaseConnection;
use CK\Query\Grammar as QueryGrammar;
use CK\Query\Processor as QueryProcessor;
use CK\Connector\Connector;

class Connection extends BaseConnection
{
    public $config;

    public $name;

    public $connector;

    public function __construct($config, $name)
    {
        $this->config = $config;
        $this->name = $name;

        $this->connector = new Connector();

        $this->useDefaultQueryGrammar();
        $this->useDefaultPostProcessor();
    }

    /**
     * get default query grammar instatnce
     *
     * @return CK\Query\Grammar
     */
    protected function getDefaultQueryGrammar()
    {
        return new QueryGrammar;
    }

    /**
     * get default processor instance
     *
     * @return CK\Query\Processor
     */
    protected function getDefaultPostProcessor()
    {
        return new QueryProcessor();
    }

    /**
     * override BaseConnection function select()
     *
     * @return array
     */
    public function select($query, $bindings = [], $useReadPdo = true)
    {
        $this->connector->execute($query, $bindings);
    }
}
